<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:syn="http://www.syniverse.com">
	<ui:define name="content">
		<p:panel header="#{msg.phieuthuchi_title}">
			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{PhieuThuChiBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":phieuThuChiForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>

			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{PhieuThuChiBean.downloadFileCSV}" ajax="false">
					<p:fileDownload value="#{PhieuThuChiBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="phieuThuChiForm">
				<p:growl id="growforFile" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />

				<p:dataTable id="dataTable" var="phieu"
					value="#{PhieuThuChiBean.listPhieuThuChi}" lazy="true"
					paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="#{msg.danhSachPhieuThuChi}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px" update=""
								value="+ thêm mới"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{PhieuThuChiBean.notifyAdd}"
								onclick="phieuThuChiDialog.show();">
							</p:commandButton>
						</div>

					</f:facet>



					<p:column headerText="#{msg.soChungTu}">#{phieu.soChungTu}  </p:column>

					<p:column headerText="#{msg.ngayLap}">  #{phieu.ngayLap}   </p:column>

					<p:column headerText="#{msg.nguoiLap}">  #{phieu.nguoiLap.hoTen}   </p:column>

					<p:column headerText="#{msg.table_actions}"
						style="text-align:center;min-width:10px">

						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-pencil" update=":addPhieuThuChiForm:display"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							action="#{PhieuThuChiBean.notifyEdit(phieu)}"
							oncomplete="phieuThuChiDialog.show();">

						</p:commandButton>

						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="confirmRemove.show();">
							<f:setPropertyActionListener value="#{phieu}"
								target="#{PhieuThuChiBean.selectedPhieuThuChi}" />
						</p:commandButton>



					</p:column>



				</p:dataTable>

			</h:form>


			<h:form id="addPhieuThuChiForm">
				<p:dialog id="dialog" header="Thêm mới/ Sửa" modal="true"
					widgetVar="phieuThuChiDialog" resizable="false">
					<p:panel id="display">
						<table>

							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="soChungTu" value="#{msg.soChungTu}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.soChungTu}: #{msg.valuerequired}"
										id="soChungTu" value="#{PhieuThuChiBean.phieuThuChi.soChungTu}">

									</p:inputText></td>
							</tr>

							<tr>

								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.ngayLap}" /></td>
								<td><p:calendar style="min-width:140px"
										value="#{PhieuThuChiBean.phieuThuChi.ngayLap}"
										pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
										<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
									</p:calendar></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="nguoiLap" value="#{msg.nguoiLap}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.nguoiLap}: #{msg.valuerequired}"
										id="nguoiLap" value="#{PhieuThuChiBean.phieuThuChi.nguoiLap.hoTen}">

									</p:inputText></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.nhanVien}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.nhanVien.maNhanVien}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{NhanVienBean.listNhanVien}"
											var="selectItem" itemLabel="#{selectItem.hoTen}"
											itemValue="#{selectItem.maNhanVien}" />
									</p:selectOneMenu></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.doiTac}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.doiTac.maDoiTac}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{DoiTacBean.listDoiTac}"
											var="selectItem" itemLabel="#{selectItem.tenDoiTac}"
											itemValue="#{selectItem.maDoiTac}" />
									</p:selectOneMenu></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px" for="caNhan"
										value="#{msg.caNhan}" /></td>
								<td><p:inputText styleClass="inputText" required="false"
										requiredMessage="#{msg.caNhan}: #{msg.valuerequired}"
										id="caNhan" value="#{PhieuThuChiBean.phieuThuChi.caNhan}">
									</p:inputText></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.donHang}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.donHang.soChungTu}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{DonHangBean.listDonHang}"
											var="selectItem" itemLabel="#{selectItem.soChungTu}"
											itemValue="#{selectItem.soChungTu}" />
									</p:selectOneMenu></td>
							</tr>
							
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.hoaDon}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.hoaDon}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value=""
											var="selectItem" itemLabel=""
											itemValue="" />
									</p:selectOneMenu></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.phieuNhapXuat}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.phieuNhapXuat.soChungTu}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{PhieuNhapXuatBean.listPhieuNhapXuat}"
											var="selectItem" itemLabel="#{selectItem.soChungTu}"
											itemValue="#{selectItem.soChungTu}" />
									</p:selectOneMenu></td>
							</tr>
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="hopDong" value="#{msg.hopDong}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.hopDong}: #{msg.valuerequired}"
										id="hopDong" value="#{PhieuThuChiBean.phieuThuChi.hopDong}">

									</p:inputText></td>
							</tr>
							
							
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.hinhThuc}" />
								</td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{PhieuThuChiBean.phieuThuChi.hinhThuc}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{PhieuThuChiBean.listHinhThuc}"
											var="selectItem" itemLabel="#{selectItem}"
											itemValue="#{selectItem}" />
									</p:selectOneMenu></td>
							</tr>
							
							

							<tr>

								<td></td>
								<td align="right"><p:commandButton value="Lưu"
										actionListener="#{PhieuThuChiBean.save}"
										update=":phieuThuChiForm :addPhieuThuChiForm:display"
										oncomplete="if(args.opSuccess) phieuThuChiDialog.hide()">
									</p:commandButton></td>
							</tr>
							



						</table>
					</p:panel>

				</p:dialog>





			</h:form>





		</p:panel>



	</ui:define>
</ui:composition>
